/*    */ package org.yaukie.auth.handler;
/*    */ 
/*    */ import com.alibaba.fastjson.JSON;
/*    */ import java.io.IOException;
/*    */ import java.io.Serializable;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.security.core.AuthenticationException;
/*    */ import org.springframework.security.web.AuthenticationEntryPoint;
/*    */ import org.springframework.stereotype.Component;
/*    */ import org.yaukie.auth.constant.AjaxResult;
/*    */ import org.yaukie.base.util.MessageTools;
/*    */ import org.yaukie.base.util.ServletUtils;
/*    */ import org.yaukie.base.util.StringTools;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Component
/*    */ public class UnAuthorizationHandler
/*    */   implements Serializable, AuthenticationEntryPoint
/*    */ {
/* 29 */   private static final Logger log = LoggerFactory.getLogger(UnAuthorizationHandler.class);
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
/* 35 */     if (log.isInfoEnabled()) {
/* 36 */       log.info("系统模块{}执行授权校验....", getClass().getSimpleName());
/*    */     }
/* 38 */     int code = 401;
/* 39 */     String msg = MessageTools.message("yaukie.user.unauthorized.error", new Object[0]);
/* 40 */     msg = StringTools.format(msg, new Object[] { request.getRequestURL() });
/* 41 */     ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
/*    */   }
/*    */ }


/* Location:              /Users/rex/Desktop/x-common-auth-1.0.0-SNAPSHOT.jar!/org/yaukie/auth/handler/UnAuthorizationHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */